$(function () {
    $("#cPlanEditTimePicker").datetimepicker({
        language :'zh-CN',
        autoclose: true,
        startDate: new Date()
    });
});

/**选择客户人员**/
function selectCalseEditUser(){
    $.post(ctx+"SaleHelp/getScalePlanCus",{},function (r) {
        $("#sale_select_user").empty().append(r).modal('show').draggable();
    });
}
/**选择模板**/
function loadeditMoadl() {
    $.post(ctx+"SaleHelp/getScalePlanModal",{},function (r) {
        $("#sale_select_user").empty().append(r).modal('show').draggable();
    });
}


/**保存计划的信息**/
function saveEditPlanDetail(btn) {
    //<input id="cPlanCusid" name="cPlanCusid" type="hidden" value="">
    $(btn).attr("disabled","disabled");
    var cPlanTime = $("#cPlanTime").val();
    if(cPlanTime == ""){$JuXue.n_danger("执行时间不能为空");return}

    /**获取标题**/
    var cPlanTitle = $("#cPlanTitle").val();
    if (cPlanTitle == ""){$JuXue.n_danger("标题不能为空");return}
    //获取时间

    //获取内容
    var cPlanDesc = $("#cPlanDesc").val();
    if (cPlanDesc == ""){$JuXue.n_danger("执行内容不能为空");return}

    var userIds = new Array();
    var userName = new Array();
    /**获取客户的信息**/
    $("#zhanshiButtonedit").find("button").each(function () {
        var uuid = $(this).attr("uuid");
        userIds.push(uuid);
        var name = $(this).text();
        userName.push(name);
    });
    $("#xialazhanshiedit").find("button").each(function () {
        var uuid = $(this).attr("uuid");
        userIds.push(uuid);
        var name = $(this).text();
        userName.push(name);
    });
    if (userIds.length <= 0){$JuXue.n_danger("执行的客户不能为空");return}
    var cPlanCusid = userIds.join(",");
    var cPlanCname = userName.join(",");
    var cPlanId = $("#editPlanId").val();

    $.post(ctx+"SaleHelp/editScalePlanforupdate",{cPlanId:cPlanId,cPlanTitle:cPlanTitle,cPlanCname:cPlanCname,
        cPlanTime:cPlanTime,cPlanDesc:cPlanDesc,cPlanCusid:cPlanCusid},function (r) {
        if (r.code == 0){
            $JuXue.n_success("编辑计划成功");
            $('#sale_help_one').empty().modal('hide');

            init_plan();
        }else{
            $JuXue.n_danger(r.msg);
            $(btn).removeAttrs("disabled");
        }
    });

}
